<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>">
	<meta charset="utf-8" />
	<title></title>
	<meta name="description" content="overview & stats" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link href="static/css/bootstrap.min.css" rel="stylesheet" />
	<link href="static/css/bootstrap-responsive.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="static/css/font-awesome.min.css" />
	<link rel="stylesheet" href="static/css/chosen.css" />
	<link rel="stylesheet" href="static/css/ace.min.css" />
	<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
	<link rel="stylesheet" href="static/css/ace-skins.min.css" />
	<link rel="stylesheet" href="static/css/datepicker.css" /><!-- 日期框 -->
	<link rel="stylesheet" href="static/css/date/bootstrap-datetimepicker.css" /><!-- 日期框 -->
	<link rel="stylesheet" href="static/css/date/bootstrap-datetimepicker.min.css" /><!-- 日期框 -->
	<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
	<!--提示框-->
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>
		
	<script type="text/javascript">
		//保存
		function save(){
			if($("#message_content").val()==""){
				$("#message_content").tips({
					side:3,
		            msg:'输入内容',
		            bg:'#AE81FF',
		            time:2
		        });
				
				$("#message_content").focus();
				return false;
			}
			
			var result = compareBeginWithEnd("start_time", "end_time");
			//alert(result);
			if(result == 1){
				alert("开始时间必须在到期时间之前！");
				$("#begintime").val("");
				$("#begintime").focus();
				return false;
			}
			
			for(var i=0;i < document.getElementsByName('city_code').length;i++){
				  if(document.getElementsByName('city_code')[i].checked){
					  var city_name = document.getElementsByName('city_code')[i].value;
					  $("#cityname").val(city_name);
				  }
			}
			
			
			//return false;
			$("#organFavoriteWelcomeForm").submit();
			$("#centerOfMainFrame").hide();
			$("#centerOfMainFrame2").show();
		}
		
		function diffDate(end) {
			var evalue = document.getElementById(end).value;
			var dB = new Date(evalue.replace(/-/g, "/"));
			if (new Date() > Date.parse(dB)) {
			       return 1;
			} 
			return 0;
		}
		
		function compareBeginWithEnd(begin, end){
			var beginTime = document.getElementById(begin).value;
			var endTime = document.getElementById(end).value;
			var dBBegin = new Date(beginTime.replace(/-/g, "/"));
			var dBEnd = new Date(endTime.replace(/-/g, "/"));
			if (Date.parse(dBBegin) > Date.parse(dBEnd)) {
			       return 1;
			} 
			return 0;
		}
	</script>
	</head>
<body>
	<c:if test="${pageData.organ_id == 1}">
	<form action="<%=basePath%>welcomemsg/goAddOrganFavoriteWelcome.do" name="cityForm" id="cityForm" method="post">
		<table>
			<tr>
				<td style="vertical-align:top;"> 
				 	<input type="text" id="city_name" name="city_name" value="${pageData.city_name}" placeholder="这里输入城市名称"/>
				</td>
				<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="searchInfo();" title="查询"><i id="nav-search-icon" class="icon-search"></i>查询</a></td>
			</tr>
		</table>
		<p><font color="red">注：未选择任何城市则代表全国适用！</font></p>
		<table id="table_report" class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th class="center">
					</th>
					<th>序号</th>
					<th>城市编号</th>
					<th>城市名称</th>
				</tr>
			</thead>
									
			<tbody>
			<!-- 开始循环 -->	
			<c:choose>
				<c:when test="${not empty varList}">
					<c:forEach items="${varList}" var="var" varStatus="vs">
						<tr>
							<td class='center' style="width: 30px;">
								<label><input name="city_code" id="city_code" type="radio" value="${var.city_name }"/><span class="lbl"></span></label>
							</td>
							<td class='center' style="width: 30px;">${vs.index+1}</td>
							<td>${var.city_code}</td>
							<td>${var.city_name }</td>
						</tr>
					</c:forEach>
					
					<!-- <tr>
						<td colspan="100" class="center">您无权查看</td>
					</tr> -->
				</c:when>
				<c:otherwise>
					<tr class="main_info">
						<td colspan="100" class="center" >没有相关数据</td>
					</tr>
				</c:otherwise>
			</c:choose>
			</tbody>
		</table>
		<div class="page-header position-relative">
			<table style="width:100%;">
				<tr>
					<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
				</tr>
			</table>
		</div>
	</form>
	</c:if>
	
	<form action="welcomemsg/saveOrganFavoriteWelcome.do" name="organFavoriteWelcomeForm" id="organFavoriteWelcomeForm" method="post" enctype="multipart/form-data">
		<input type="hidden" name="organ_id" id="organ_id" value="${pageData.organ_id }"/>
		<input type="hidden" name="cityname" id="cityname"/>
		<div id="centerOfMainFrame">
			<table id="table_report" class="table table-striped table-bordered table-hover">
				<tr>
					<td>内容:</td>
					<td>
						<textarea  style="width:93%;height:290px" name="message_content" id="message_content"></textarea>
					</td>
				</tr>
				<tr>
					<td>欢迎链接:</td>
					<td><input type="text" style="width:95%;" name="message_link" id="message_link" placeholder="这里输入链接" title="链接"/></td>
				</tr>
				<tr>
					<td>上传:</td>
					<td>
						<input type="file" id="message_imageurl" name="message_imageurl"/>
					</td>
				</tr>
				<tr>
					<td>状态:</td>
					<td>
						<select name="status" title="状态">
							<option value="1">已启用</option>
							<option value="0">未启用</option>
						</select>
					</td>
				</tr>
				<c:if test="${pageData.organ_id == 1}">
				<tr>
					<td>使用类型:</td>
					<td>
						<select name="type" title="状态">
							<option value="1">首次注册用户使用</option>
							<option value="2">非首次注册用户使用</option>
						</select>
					</td>
				</tr>
				</c:if>
				<tr>
					<td>有效时间:</td>
					<td>
						<input style="width:35%;" class="form_datetime" name="start_time" id="start_time" type="text" readonly placeholder="开始时间" title="开始时间"/>
						<input style="width:35%;" class="form_datetime" name="end_time" id="end_time" type="text" readonly placeholder="到期时间" title="到期时间"/>
					</td>
				</tr>
				<tr>
					<td class="center" colspan="2">
						<a class="btn btn-mini btn-primary" onclick="save();">保存</a>
						<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
					</td>
				</tr>
			</table>
		</div>
		<div id="centerOfMainFrame2" class="center" style="display:none"><br/><br/><br/><br/><br/><img src="static/images/jiazai.gif" /><br/><h4 class="lighter block green">提交中...</h4></div>
	</form>
		
	<!-- 引入 -->
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
	<script type="text/javascript" src="static/js/ace.min.js"></script>
	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
	<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
	<script type="text/javascript" src="static/js/date/bootstrap-datetimepicker.js" charset="UTF-8"></script>
	<script type="text/javascript" src="static/js/date/bootstrap-datetimepicker.zh-CN.js"></script><!-- 日期框 -->
	<!-- 编辑框-->
	<script type="text/javascript" charset="utf-8">window.UEDITOR_HOME_URL = "<%=path%>/plugins/ueditor/";</script>
	<script type="text/javascript" charset="utf-8" src="plugins/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="plugins/ueditor/ueditor.all.js"></script>
	<!-- 编辑框-->
	<script type="text/javascript">
	$(top.hangge());
	$(function() {
		
		//单选框
		$(".chzn-select").chosen(); 
		$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
		
		//日期框
		$('.date-picker').datepicker();
		
		//上传
		$('#message_imageurl').ace_file_input({
			no_file:'请选择图片 ...',
			btn_choose:'选择',
			btn_change:'更改',
			droppable:false,
			onchange:null,
			thumbnail:false //| true | large
			//whitelist:'gif|png|jpg|jpeg'
			//blacklist:'exe|php'
			//onchange:''
			//
		});
		
		//日期框
		//$('.date-picker').datepicker();
		$(".form_datetime").datetimepicker({
			language:  'zh-CN',
			weekStart: 1,
	        todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			forceParse: 0,
	        //showMeridian: 1,
			format: 'yyyy-mm-dd hh:ii'
			});
	});
	
	function reurl(){ 
		UE.getEditor('message_content');
	} 
	
	function searchInfo(){
		$("#cityForm").submit();
	}
	setTimeout('reurl()',500);
	</script>
</body>
</html>